home *** CD-ROM | disk | FTP | other *** search
- ;void string_line(strg,dir,col,row,length,color);
- ; unsigned char *strg,dir,col,row,length,color;
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _string_line
- _string_line proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;save TURBO's DS
- cld ;set direction flag
- mov ax,_video_buffer ;fetch _video_buffer
- mov es,ax ;shift to ES
- sub ax,ax ;
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- inc bp ;add 2 to BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov si,[bp+4] ;
- L00: mov [bp+4],si ;move Strg ptr in FAR case
- mov al,[bp+10] ;get ROW value
- dec ax ;count from 0
- mov dl,160 ;160 bytes per line
- mul dl ;times number rows
- sub bx,bx ;
- mov bl,[bp+8] ;get COL value
- mov di,bx ;
- dec di ;count from 0
- shl di,1 ;double for attri bytes
- add di,ax ;now ES:DI pts to 1st pos
- sub cx,cx ;
- mov cl,[bp+12] ;string length in CX
- jcxz L7 ;quit if null
- mov ah,[bp+14] ;attribute in AH
- mov bl,[bp+6] ;get direction param
- mov dx,158 ;offset for vertical
- cmp bl,'V' ;write vertically?
- je L1 ;jump ahead if so
- cmp bl,'v' ;test small 'v' also
- je L1 ;jump if small 'v'
- sub dx,dx ;zero offset if horz
- L1: mov [bp+14],dx ;save offset on stack
- cmp byte ptr[si],0 ;test for null string
- je L7 ;
- L2: mov al,[si] ;get a character
- inc si ;forward Strg pointer for next time
- cmp al,0 ;end of string?
- jne L3 ;jump ahead if not
- mov si,[bp+4] ;pt back to start of Strg
- jmp short L2 ;go get first char of string
- L3: mov dx,es ;ES pts to video buffer
- cmp dx,0b800h ;test for graphics card
- jb L6 ;jump if not graphics
- mov dx,3dah ;status byte address
- mov bx,ax ;save AX contents
- L4: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L4 ;loop till 0
- cli ;disable interrupts
- L5: in al,dx ;get status byte
- test al,1 ;test bit
- jz L5 ;loop till 1
- mov ax,bx ;restore AX contents
- L6: stosw ;write a char and attri
- add di,[bp+14] ;add offset to next chr
- loop L2 ;go write next
- sti ;reenable interrupts
- L7: pop ds ;
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _string_line endp
- _TEXT ENDS
- END